// script.aculo.us dragdrop.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008

// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//           (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/

//拖动窗口
var ie = document.all;   
var nn6 = document.getElementById&&!document.all;   
var isdrag = false;   
var y,x;   
var oDragObj;   


function moveMouse(e) {   
	if (isdrag) {   
		oDragObj.style.top = (nn6 ? nTY + e.clientY - y : nTY + event.clientY - y)+"px";   
		oDragObj.style.left = (nn6 ? nTX + e.clientX - x : nTX + event.clientX - x)+"px"; 
	    //限制范围
	    var currentX=parseInt(oDragObj.style.left); 
	    var currentY=parseInt(oDragObj.style.top);
	    var maxX=parseInt(document.body.clientWidth)-parseInt($('popDiv').clientWidth);
	    var maxY=parseInt(document.body.clientHeight)-parseInt($('popDiv').clientHeight);
	    
	    if(currentX < 0){
	        oDragObj.style.left=0+"px";
	    }
	    if(currentY < 0){
	        oDragObj.style.top=0+"px";
	    }
	    if(currentX > maxX){
	        oDragObj.style.left=maxX+"px";
	    }
	    if(currentY > maxY){
	        oDragObj.style.top=maxY+"px";
	    } 
		return false;   
	}   
}   

function initDrag(e) {   
	var oDragHandle = nn6 ? e.target : event.srcElement;   
	while (oDragHandle.tagName && oDragHandle.tagName!= "HTML" && oDragHandle.className != "DragAble") {   
		oDragHandle = nn6 ? oDragHandle.parentNode : oDragHandle.parentElement;   
	}   
	if (oDragHandle.className=="DragAble") {   
		isdrag = true;   
		oDragObj = oDragHandle.parentNode;   
		nTY = parseInt(oDragObj.style.top);   
		y = nn6 ? e.clientY : event.clientY;   
		nTX = parseInt(oDragObj.style.left);   
		x = nn6 ? e.clientX : event.clientX;   
		document.onmousemove = moveMouse;   
		return false;   
	}   
}   
document.onmousedown = initDrag;   
document.onmouseup = new Function("isdrag=false");  

function setwindow(){
	 temp_h1 = document.body.clientHeight;
	 temp_h2 = document.documentElement.clientHeight;
	 isXhtml = (temp_h2<=temp_h1&&temp_h2!=0)?true:false;
	 htmlbody = isXhtml?document.documentElement:document.body;
	 newdivs = false;
	 if (newdivs){
	  newdivs = false;
	  htmlbody.style.overflow = "auto";
	 }else{
	  newdivs = true;
	  htmlbody.style.overflow = "hidden";
	 }
}

//关闭显示
function closeShow(divid)
{
  var newbox = document.getElementById(divid);
  layer.style.display="none";
  newbox.style.display="none";
  htmlbody = isXhtml?document.documentElement:document.body;
  htmlbody.style.overflow = "auto";
}

//遮罩层
function mask()
{
	var isIE = (document.all) ? true : false;
	var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
	layer=document.createElement("div");
	layer.id="layer";
	layer.style.width=layer.style.height="100%";
	layer.style.position= !isIE6 ? "fixed" : "absolute";
	layer.style.top=layer.style.left=0;
	layer.style.backgroundColor="#000";
	layer.style.zIndex="1";
	layer.style.opacity="0.6";
	document.body.appendChild(layer);
	function layer_iestyle(){      
	layer.style.width=Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)+ "px";
	layer.style.height= Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) +"px";
	}
	if(isIE){layer.style.filter ="alpha(opacity=60)";}
	if(isIE6){  
		layer_iestyle();
		window.attachEvent("onresize",layer_iestyle)          
	}  
}